<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="name here">
	<meta name="author" content="name here">

	<title>Title here</title>

	<link rel="stylesheet" href="css/jquery.mobile.structure-1.3.0.css">
	<link rel="stylesheet" href="themes/BancoDelPeru.css">

	<script src="js/jquery-1.9.1.js"></script>
	<script src="js/jquery.mobile-1.3.0.js"></script>
	<script type="text/javascript" src="js/cordova-2.5.0.js" charset="utf-8"></script>
	<script src="js/configs.js"></script>


<script type="text/javascript" charset="utf-8">
		function iniciar() {			
			document.addEventListener("deviceready", dispositivoListo, false);			
		}
		function dispositivoListo() {
						
		}
		
		function sendAnswer() {
			var customerID =  window.localStorage["customerID"];
			var question = $("#lstQuestions").val();
			var answer = $("#txtAnswer").val();
			
			console.log("xxxxxxxxxxxxxxx" + customerID);
			console.log("xxxxxxxxxxxxxxx" + question);
			console.log("xxxxxxxxxxxxxxx" + answer);
			
			$.post("http://"+SERVER_IP_ADDRESS+":8080/WebBancoPeru/rest/customer/security", {customerID: customerID, Question: question, Answer: answer}, function(data){
				
				console.log("xxxxxxxxxxxxxxx" + data.status);
				if("false" == data.status)			{
						console.log(data.status);
						alert("Answer provided was wrong, please login again!");
						window.location.assign("login.html");
				}
				
				else if("true" == data.status){
					alert("Answer is correct!");
					window.location.assign("mainmenu.html");					
				}
				
				
			}, "json");
		}
		
	</script>
</head>
<body onload="iniciar()">


	<div data-role="page">
		<div data-role="header" data-position="fixed">
			<h1>Banco Per&uacute;</h1>
		</div>

		<div data-role="content">
			<label for="text-basic">Security Question:</label> <select
				id="lstQuestions">
				<option>What is your favorite dish?</option>
				<option>What is the name of your pet?</option>
				<option>Who is PISADO in this room?</option>
				<option>What is your favorite sport?</option>
				<option>Where did you develop this app?</option>
			</select> <label for="text-basic">Answer:</label> <input type="password"
				name="answer" id="txtAnswer" class="required"
				placeholder='Write your answer here' /> 
				<a data-role="button" href="#" data-inline="true" onclick="sendAnswer()">Submit Answer</a>


			<div data-role="footer" data-position="fixed">
				<h1>Banco Per&uacute; &copy; 2013</h1>
			</div>
		</div>
	</div>